package com.gzhu.knowledgeAdmin.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.Page;
import com.gzhu.knowledgeAdmin.common.result.R;
import com.gzhu.knowledgeAdmin.entity.Gsxx;
import com.gzhu.knowledgeAdmin.entity.PageBean;
import com.gzhu.knowledgeAdmin.entity.TXtcsT;
import com.gzhu.knowledgeAdmin.service.XtcxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/xtcs")
public class XtcsController {
    @Autowired
    XtcxService xtcxService;

    @PostMapping("/selectALl")
    public R selectALl(Integer pageNum,
                        Integer  pageSize,
            @RequestParam(required = false)String fgsid){
        System.out.println(pageNum+"--"+pageSize+"--"+fgsid);


        PageBean<TXtcsT> list = xtcxService.selectAll(pageNum,pageSize,fgsid);

        return R.ok(list);

    }
    @PostMapping("/insert")
    public R insert(@RequestBody TXtcsT tXtcsT){



        boolean list = xtcxService.save(tXtcsT);


        return R.ok(list);
    }
    @PostMapping("/update")
    public R update(@RequestBody TXtcsT tXtcsT){


        System.out.printf(String.valueOf(tXtcsT));
        boolean list = xtcxService.updateById(tXtcsT);


        return R.ok(list);
    }
    @PostMapping("/delete")
    public R delete(@RequestBody TXtcsT tXtcsT){

        System.out.printf(String.valueOf(tXtcsT));
        boolean list = xtcxService.removeById(tXtcsT.getFId());



        return R.ok(list);
    }
    @PostMapping("/selectCALLSERVER")
    public R selectCALLSERVER(){

        LambdaQueryWrapper<TXtcsT> lambdaQueryWrapper=new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(TXtcsT::getFCsm,"CALL_SERVER");
        TXtcsT tXtcsT=xtcxService.getOne(lambdaQueryWrapper);
        System.out.printf(String.valueOf(tXtcsT));
        return R.ok(tXtcsT);
    }

}
